#include "inputBox.h"
#include "util.h"
#include "global.h"
#include <string.h>
void InputBox_show(SDL_Renderer *renderer, InputBox *inputBox,TTF_Font *font, TextTexture *textTexture)
{
    SDL_SetRenderDrawColor(renderer, inputBox->color.r, inputBox->color.g, inputBox->color.b, inputBox->color.a);
    SDL_RenderFillRect(renderer, &inputBox->rect);
    if(strlen(inputBox->text)!=0)
    textTexture->drawText(renderer, textTexture, font, inputBox->text, inputBox->rect.x+FONT_SIZE/2, inputBox->rect.y+FONT_SIZE/2, 1.0f, textTexture->defaultColor);

}
void InputBox_setClickEvent(InputBox *inputBox, void (*func))
{
}
void InputBox_clickEvent()
{
}

void InputBox_init(InputBox *self, const char *name,const char *text, SDL_Rect rect, SDL_bool enabled, SDL_Color color, SDL_Color textColor)
{
    size_t len = strlen(name);
    self->name =malloc(len + 1);
    memcpy(self->name, name, len);
    self->name[len] = '\0';
    size_t len2 = strlen(text);
    self->text = malloc(len + 1);
    memcpy(self->text, text, len2);
    self->text[len2] = '\0';
    self->rect = rect;
    self->editing = SDL_FALSE;
    self->enabled = enabled;
    self->color =color;
    self->textColor = textColor;
}
CTOR(InputBox)
FUNCTION_SETTING(show,InputBox_show);
FUNCTION_SETTING(init,InputBox_init);
FUNCTION_SETTING(setClickEvent,InputBox_setClickEvent);
FUNCTION_SETTING(clickEvent,InputBox_clickEvent);

END_CTOR